package controllers

import (
	"github.com/gin-gonic/gin"
	_ "go_pure_admin_api/models"
	"net/http"
)

type BaseController struct {
}

type ResponseJson struct {
	Success bool   `json:"success"`
	Msg     string `json:"msg"`
	Data    any    `json:"data"`
}

// Success 200 OK - 成功响应
func (b *BaseController) Success(ctx *gin.Context, msg string, data any) {
	ctx.AbortWithStatusJSON(http.StatusOK, ResponseJson{
		Success: true,
		Msg:     msg,
		Data:    data,
	})
}
func (b *BaseController) Fail(ctx *gin.Context, code int, msg string, data any) {
	ctx.AbortWithStatusJSON(code, ResponseJson{
		Success: false,
		Msg:     msg,
		Data:    data,
	})
}
